<?php echo $this->element('displayHeader'); ?>

<fieldset>
    <legend>Site Information</legend>
    <table>
        <tr>
            <td width="120px"><?php echo $form->label('Site.site_no', 'Site no'); ?></td>
            <td><?php echo $site['Site']['site_no']; ?></td>
        </tr>
        <tr>
            <td><?php echo $form->label('Site.name', 'Site name'); ?></td>
            <td><?php echo $site['Site']['name']; ?></td>
        </tr>
    </table>
</fieldset>

<div class="toolbar">
    <?php if ($session->read('Auth.User.can_add_location') == true) : ?>
        <?php echo $this->element('toolbar', array('buttons' => array('add', 'search', 'refresh'))); ?>
    <?php else : ?>
        <?php echo $this->element('toolbar', array('buttons' => array('search', 'refresh'))); ?>
    <?php endif; ?>
</div>
<?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
<?php echo $this->element('dataNotFound'); ?>
<? else : // ถ้ามีข้อมูล ?>

    <?php $paginator->options(array('update' => 'content', 'indicator' => 'indicator', 'url' => array('controller' => 'cust_locations', 'action' => 'display'))); ?>
    <?php echo $this->element('dataCaptionLimit'); ?>
    <?php $cur = $paginator->counter(array('format' => '%start%')); ?>

<table class="data">
    <thead>
        <tr>
            <th class="no"><?php echo $paginator->sort('No', 'id'); ?></th>
            <th><?php echo $paginator->sort('Name', 'Location.name'); ?></th>
            <?php if ($session->read('Auth.User.can_add_location') == true) : ?>
            <th class="action">&nbsp;</th>
            <?php endif; ?>
        </tr>
    </thead>
    <tbody>
            <?php $i = 0; foreach($this->data as $i => $data): ?>
        <tr class="<?php echo (($i + 1) % 2 == 0)? 'even-cell' : 'odd-cell'; ?>">
            <td class="center"><?php echo $i + 1; ?></td>
            <td class="text-left"><?php echo $data['CustLocation']['name']; ?></td>
            <?php if ($session->read('Auth.User.can_add_location') == true) : ?>
            <td>
                        <?php echo $ajax->link( $html->image('icon/edit.png', array('title' => 'view', 'alt' => 'view')), '/cust_locations/view/' . $data['CustLocation']['id'],
                        array('indicator' => 'indicator', 'update' => 'content'), null, false); ?>
            </td>
            <?php endif; ?>
        </tr>
            <?php endforeach; ?>
    </tbody>
</table>
    <?php echo $this->element('paging'); ?>
<? endif; ?>
